<%@ Page Title="" Language="C#" MasterPageFile="~/Areas/Admin/Views/Shared/Admin.Master" Inherits="System.Web.Mvc.ViewPage<IEnumerable<mesoBoard.Data.ReportedPost>>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">  
    <script type="text/javascript">

        function toggleText(num) {
            var link = $("#link" + num);
            var rpost = $("#reportedpost" + num);
            if (rpost.is(":visible")) {
                rpost.hide();
                link.html("(show text)");
            } else {
                rpost.show();
                link.html("(hide text)");
            }
            return;
        }

        $(function () {
            $(".reported-post-text").hide();
            $(".reported-post-link").click(function () {
                return false;
            });
        });
        
    </script>
      
    <fieldset>
        <legend><%= Html.ThemeImage("report.png") %> Reported Posts</legend>
        <table class="form_table">
            <tr>
                <th>Go to Post</th>
                <th>Post Text</th>
                <th>Thread</th>
                <th>Date</th>
                <th></th>
                <th></th>
            </tr>
            
            <% if (Model.Count() == 0){ %>
            <tr>
                <td colspan="4" style="text-align: center">No reported posts</td>
            </tr>
            <% } %>
            
            <% foreach(ReportedPost rp in Model.OrderByDescending(x=>x.Date)){ %>
            <tr>
                <td>
                    <a href="<%= Url.Action("ViewThread", "Board", new { ThreadID = rp.Post.ThreadID, PostID = rp.PostID }) + "#" + rp.PostID %>">
                    Go
                    </a>
                </td>
                <td>
                    <%= rp.Post.Text.Shorten(25) %> <a class="reported-post-link" href="#" onclick="javascript: toggleText(<%= rp.PostID %>); return;" id="link<%= rp.PostID %>">(show text)</a>
                    <div id="reportedpost<%= rp.PostID %>" class="reported-post-text">
                        <hr />
                        <%= rp.Post.ParsedText %>
                    </div>
                </td>
                <td><%= Html.ActionLink(rp.Post.Thread.FirstPost.Title, "ViewThread", "Board", new { ThreadID = rp.Post.ThreadID }, "") %></td>
                <td><%= Html.RelativeDate(rp.Date) %></td>
                <td><%= Html.ActionLink("Mark as Safe", "MarkAsSafe", new { ReportedPostID = rp.PostID }) %></td>
                <td><%= Html.AdminConfirm("Delete Post", Url.Action("DeletePost", "Post", new { PostID = rp.PostID }), Url.Action("Index")) %></td>
            </tr>
            <% } %>
        </table>
    </fieldset>    

</asp:Content>
